package com.fymxy.question_bank_management.mapper;

import com.fymxy.question_bank_management.pojo.Teacher;

import java.util.List;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

@Mapper
@Component
public interface TeacherMapper {
    @Update("update teacher set teacher_name=#{name},teacher_mail=#{email} where teacher_no=#{teacherNo} ")
    int update(int teacherNo, String name,String email);
    //插入teacher
    @Insert("insert into teacher (teacher_name,teacher_nickname,teacher_pwd,teacher_mail,teacher_discipline) values "+
            "(#{teacherName},#{teacherNickname},#{teacherPwd},#{teacherMail},#{teacherDiscipline})")
    int insert(Teacher record);

    int insertSelective(Teacher record);

    @Select("select teacher_no,teacher_nickname,teacher_name,teacher_pwd,teacher_discipline,teacher_mail from teacher where teacher_nickname = #{username} and teacher_pwd = #{password}")
    @Results(id = "teacherMap",value = {
            @Result(column = "teacher_no",property = "teacherNo",id = true),
            @Result(column = "teacher_name",property = "teacherName"),
            @Result(column = "teacher_pwd",property = "teacherPwd"),
            @Result(column = "teacher_nickname",property = "teacherNickname"),
            @Result(column = "teacher_discipline",property = "teacherDiscipline"),
            @Result(column = "teacher_mail",property = "teacherMail")
    })
    Teacher teacherLogin(String username, String password);

    @Select("select teacher_nickname from teacher")
    List<String> getTeacherNicknames();


}